Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ypes Re-export FieldCondition, SubcategoryFieldDef, SubcategoryStructure from funpayparsers.types.subcategory_structure via a new types module. Add field_schema: list[SubcategoryFieldDef] field to OfferFields and a subcategory_structure property that builds a SubcategoryStructure on demand. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
FieldCondition, SubcategoryFieldDef and SubcategoryStructure are now proper Pydantic models inheriting from FunPayObject instead of re-exporting the funpayparsers dataclasses directly. Each class owns its _add_raw_source validator: - FieldCondition/SubcategoryStructure: no raw_source on the parser side, generate a stable JSON identifier on construction - SubcategoryFieldDef: raw_source already present on the parser dataclass, let from_attributes carry it through; fallback for dict construction SubcategoryStructure.from_offer_fields is added as a classmethod and used by OfferFields.subcategory_structure property. OfferFields.field_schema now stores engine SubcategoryFieldDef instances. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rets' Mirrors funpayparsers cbbbd5b. Without this, saving auto-delivery secrets through the engine writes the wrong form key and FunPay silently drops it.
Mirrors funpayparsers PR #102 (b942fae). The listing page parser populates SubcategoryStructure from data-fields JSON; without this field the structure was silently dropped on the engine side.
…e matching with parser - label_map / lower_label_map now return dict[str, list[str]] and use cached_property, matching funpayparsers 66e6cd0. Previously a single-id dict silently dropped fields with duplicate labels (notably empty labels on form fields without <label>). - FieldCondition.is_satisfied_by and stored values are case-insensitive via casefold, mirroring parser fc6190d. FunPay's listing page and offerEdit form render the same value with inconsistent casing.
Mirrors funpayparsers f2d2851. The parser stamps subcategory context (OFFERS/CHIPS) onto every preview based on the offer URL; the engine wrapper was dropping it.
…tegoryStructure validator The parser ships SubcategoryStructure as a plain @DataClass (no FunPayObject mixin). When pydantic ingests a parser instance via model_validate, the existing 'before' validator only handled dict input and returned dataclass instances unchanged, causing 'raw_source: Field required' validation errors on every page that actually has a populated structure (e.g. subcat 1, 27, 41). Mirrors the same pattern already used for FieldCondition. Verified on live subcategories with rich filter blocks.
…fferPage.images Mirrors funpayparsers (types/pages/order_page.py:53, types/pages/offer_page.py:48). Both helpers were missing in engine, breaking the documented flow: message.meta.order_id -> get_order_page -> structure -> field_id mapping. Also adds OfferPage.images (engine wrapper was missing the list parsed from div.param-list attachments). Verified end-to-end on live FunPay session.
…ields, OrderPage data split
Surfaces the new structural-parsing primitives from funpayparsers
feature/multi-source-label-index in the engine wrappers:
- SubcategoryFieldDef.aliases (casefolded set of cross-locale label aliases)
- SubcategoryStructure.label_map / lower_label_map now index aliases too,
plus lookup_field_id(), add_alias(), enrich_from_offer() helpers
- OfferPreview.parse_title_fields(structure) and
OrderPreview.parse_title_fields(structure) — delegate to parser's
_parse_title_fields, extract NUMERIC_RANGE/SELECT/DROPDOWN suffix fields
from comma-separated titles
- OrderPage.metadata (canonical-keyed stable order metadata) and
lot_fields (everything else); get_structured_fields now operates on
lot_fields, eliminating false matches against order metadata labels.
Properties (short_description, amount, …) read from metadata directly.
- OrderPage.data kept for backwards compatibility.
Live recall on real subcategories:
- OfferPage.get_structured_fields: 0 → 3 matches after enrich_from_offer
- OrderPreview.parse_title_fields on subcat #1316 yields
{currency: USD, usd: 20 USD} from a real purchase title.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
funpayparsersdependency from>=0.7.0,<0.8.0to>=0.8.0,<0.9.0funpaybotengine.typesChanges
New module —
types/subcategory_structure.pyRe-exports three new types from
funpayparsers.types.subcategory_structure:FieldCondition— visibility condition for a subcategory field (field_id+ set of triggervalues)SubcategoryFieldDef— full definition of a single subcategory field (id, type, label, conditions, options)SubcategoryStructure— derived structure for O(1) lookup by field ID, withlabel_mapandlower_label_map(case-insensitive)Note:
SubcategoryFieldTypeenum is already available viaenums.py(re-exported from funpayparsers).OfferFields— two new membersfield_schema: list[SubcategoryFieldDef]— populated byOfferFieldsParserfrom thedata-fieldsJSON attribute; empty list for chips offerssubcategory_structureproperty — builds aSubcategoryStructurefromfield_schemaon demandBreaking changes
None. All additions are backwards-compatible (
field_schemadefaults to[])